package com.lancoo.edu.platform.operation.commons.service.async;

import cn.hutool.core.date.DateUtil;
import com.lancoo.edu.platform.operation.commons.config.LancooConfig;
import com.lancoo.edu.platform.operation.commons.domain.logSystem.PushLogInfo;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * @author lzh
 * @Description: 异步推送日志 --- 不影响主线程操作
 */
@Slf4j
@Service
@AllArgsConstructor
public class AsyncPushLogService {
    // private final Sys894LogSystemApiService sys894LogSystemApiService;

    /**
     * 推送办公平台日志
     * @param userId 用户ID
     * @param userName 用户名
     * @param operationType 操作类型
     * @param modelId 模块ID
     * @param modelName 模块名称
     * @param operationContent 操作描述
     * @param remark 备注字段
     * @param eduId 教育局ID
     */
    @Async("discardPolicyTaskExecutor")
    public void push264Log (String userId,String userName,Integer operationType,String modelId,String modelName,String operationContent,String remark,String eduId){
        PushLogInfo pushLogInfo = new PushLogInfo();
        pushLogInfo.setSysId(LancooConfig.SYS_ID);
        pushLogInfo.setSysName(LancooConfig.SYS_NAME);
        //buildPushLog(userId, userName, operationType, modelId, modelName, operationContent, remark, schoolId, pushLogInfo);
    }



    /**
     * 构建推送日志实体并推送
     * @param userId 用户ID
     * @param userName 用户名
     * @param operationType 操作类型
     * @param modelId 模块ID
     * @param modelName 模块名称
     * @param operationContent 操作描述
     * @param remark 备注字段
     * @param schoolId 学校ID
     * @param pushLogInfo 日志信息
     */
    private void buildPushLog(String userId, String userName, Integer operationType, String modelId, String modelName, String operationContent, String remark, String schoolId, PushLogInfo pushLogInfo) {
        pushLogInfo.setUserId(userId);
        pushLogInfo.setUserName(userName);
        pushLogInfo.setModelId(modelId);
        pushLogInfo.setModelName(modelName);
        pushLogInfo.setOperationTime(DateUtil.date());
        pushLogInfo.setOperationTerminal(1);
        pushLogInfo.setOperationType(operationType);
        pushLogInfo.setOperationContent(operationContent);
        pushLogInfo.setRemark(remark);
        pushLogInfo.setEduId(schoolId);
        //sys894LogSystemApiService.pushLog(Collections.singletonList(pushLogInfo));
    }
}
